home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / games / texturemapping / movement.asm < prev    next >
Assembly Source File  |  1980-01-03  |  1KB  |  71 lines

  1. ; $$TABS=8
  2.  
  3.     include    'demo.i'
  4.  
  5.     xref    frfract,read_joystick
  6.     xref    stick_right,stick_left,stick_down,stick_up,stick_click
  7.     xref    sincos
  8.  
  9. ; movement routines
  10.  
  11. DoMovement::
  12. ; read the joystick and move the player
  13.     clr.w    Moved(a6)
  14.     bsr    read_joystick
  15. no_freeze_player:
  16.     move.w    frfract(a6),d0
  17.     lsr.w    #2,d0    ; 8 second rotation
  18.     tst.b    stick_right(a6)
  19.     beq.s    no_right
  20.     st    Moved(a6)
  21.     add.w    d0,PlayerHeading(a6)
  22. no_right:
  23.     tst.b    stick_left(a6)
  24.     beq.s    no_left
  25.     sub.w    d0,PlayerHeading(a6)
  26.     st    Moved(a6)
  27. no_left:
  28.     clr.w    PlayerSpeed(a6)
  29.     tst.b    stick_up(a6)
  30.     beq.s    no_speedup
  31.     move.w    #2048,PlayerSpeed(a6)
  32. no_speedup:
  33.     tst.b    stick_down(a6)
  34.     beq.s    no_slowdown
  35.     move.w    #-2048,PlayerSpeed(a6)
  36. no_slowdown:
  37. ; ok, now we have the variables updated, so let's move the guy!
  38.     move.w    PlayerHeading(a6),d0
  39.     bsr    sincos    ; d0=sin d1=cos
  40.     move.w    frfract(a6),d2
  41.     muls    d2,d0
  42.     muls    d2,d1
  43.     add.l    d0,d0
  44.     add.l    d1,d1
  45.     swap    d0
  46.     swap    d1
  47.     move.w    PlayerSpeed(a6),d2
  48.     or.w    d2,Moved(a6)
  49.     muls    d2,d0
  50.     muls    d2,d1
  51.     add.l    d0,d0
  52.     add.l    d1,d1
  53.     swap    d0
  54.     swap    d1
  55.     ext.l    d0
  56.     ext.l    d1
  57.     add.l    d0,PlayerX(a6)
  58.     add.l    d1,PlayerZ(a6)
  59.     rts
  60.  
  61.  
  62.     section    __MERGED,data
  63.  
  64. PlayerX::    dc.l    0
  65. PlayerY::    dc.l    1000
  66. PlayerZ::    dc.l    0
  67.  
  68. Moved::    dc.w    0
  69. PlayerSpeed::    dc.w    0
  70. PlayerHeading::    dc.w    0
  71.